import React from "react";
import { useShallow } from "zustand/react/shallow";
import EchartsInstance from "@/components/EchartsInstance";
import { useGlobalStore } from "@/stores";
import { mapOptions } from "./options";

interface Props {
  data: Record<string, any>;
}

const Map: React.FC<Props> = (props) => {
  const { renderer } = useGlobalStore(useShallow((state) => ({ renderer: state.renderer })));

  const config = mapOptions(props.data);

  return <EchartsInstance className="w-[920px] h-[650px]" renderer={renderer} options={config} />;
};

export default React.memo(Map);
